﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DA
{
    public class DanhSachPhong_DA
    {
        QLKhachSanDataContext ql;
        public List<DanhSachPhong> LayDSPhong()
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.DanhSachPhongs.ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ql.Dispose();
            }
        }
        public object LayGiaPhongTheoMa(string ma)
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.DanhSachPhongs.Where(p => p.MaLoai == ma).Select(p => p.DanhMucPhong.DonGia).FirstOrDefault();
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                ql.Dispose();
            }
        }
        public string LayMaLoaiTheoMa(string ma)
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.DanhSachPhongs.Where(p => p.MaPhong == ma).Select(p => p.MaLoai).FirstOrDefault();
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                ql.Dispose();
            }
        }
    }
}
